import {request} from '@umijs/max';
import * as API from "@/services";


/** 期刊收藏 分页检索请求 */
export async function queryJournalCollections(params: API.JournalCollectionPageQueryParams): Promise<API.RespPageResult<API.JournalCollection>> {
  return request('/api/v1/journal-collection', {
    params,
  });
}

/** 期刊收藏 详情请求 */
export async function queryJournalCollection(bizId: API.EntityId): Promise<API.RespResult<API.JournalCollection>> {
  return request(`/api/v1/journal-collection/${bizId}`);
}



/** 期刊收藏（当前用户） */
export async function collectionJournalReq(bizId: API.EntityId): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/journal-collection/${bizId}/collection`, {
    method: 'PATCH',
  });
}

/** 取消期刊收藏（当前用户） */
export async function unCollectionJournalReq(bizId: API.EntityId): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/journal-collection/${bizId}/uncollection`, {
    method: 'PATCH',
  });
}

/** 期刊是否被收藏（当前用户） */
export async function hasCollectionJournalReq(bizId: API.EntityId): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/journal-collection/${bizId}/hascollection`, {
    method: 'PATCH',
  });
}

/** 期刊被收藏数量 */
export async function queryJournalCollectionNum(bizId: API.EntityId): Promise<API.RespResult<number>> {
  return request(`/api/v1/journal-collection/${bizId}/collectionnum`, {
    method: 'PATCH',
  });
}


/** 我的收藏列表 */
export async function queryMyJournalCollections(params: API.PageQueryParams): Promise<API.RespPageResult<API.JournalCollection>> {
  return request(`/api/v1/journal-collection/mycollection`, {
    method: 'GET',
    params,
  });
}

